<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>补缴税费</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            text-align: center;
            color: #333;
        }
        .container {
            background-color: #f9f9f9;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input[type="number"] {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .buttons {
            display: flex;
            justify-content: space-between;
            margin-top: 20px;
        }
        button {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        #calculate {
            background-color: #4CAF50;
            color: white;
        }
        #reset {
            background-color: #f44336;
            color: white;
        }
        #result {
            margin-top: 20px;
            padding: 10px;
            background-color: #e7f3fe;
            border-left: 6px solid #2196F3;
            display: none;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
    </style>
</head>
<body>
    <h1>税费缴补</h1>
    <div class="container">
        
        <div class="form-group">
            <label for="salary">计税工资（元）:</label>
            <input type="number" id="salary" placeholder="请输入计税工资">
        </div>
        
        <div class="form-group">
            <label for="extra-income">其他收入（元）:</label>
            <input type="number" id="extra-income" placeholder="请输入其他收入">
        </div>
        
        <div class="buttons">
            <button id="calculate">计算</button>
            <button id="reset">重置</button>
        </div>
        
        本次需要补缴的税费金额为:<div id="result"></div>
    </div>

    <script>
        document.getElementById('calculate').addEventListener('click', function() {
            const salary = parseFloat(document.getElementById('salary').value);
            const extraIncome = parseFloat(document.getElementById('extra-income').value);
            
            if (isNaN(salary) || isNaN(extraIncome)) {
                alert('请输入有效的数字！');
                return;
            }
            
            // 计算补缴税费
            const tax = calculateAdditionalTax(salary, extraIncome);
            
            // 显示结果
            const resultElement = document.getElementById('result');
            resultElement.style.display = 'block';
            resultElement.innerHTML = ` <strong>${tax.toFixed(2)}</strong> 元`;
        });
        
        document.getElementById('reset').addEventListener('click', function() {
            document.getElementById('salary').value = '';
            document.getElementById('extra-income').value = '';
            document.getElementById('result').style.display = 'none';
        });
        
        function calculateAdditionalTax(salary, extraIncome) {
            // 计算原应纳税所得额
            const originalTaxableIncome = salary - 3500;
            
            // 计算新应纳税所得额
            const newTaxableIncome = salary + extraIncome - 3500;
            
            // 如果应纳税所得额小于等于0，不需要缴税
            if (newTaxableIncome <= 0) {
                return 0;
            }
            
            // 计算原税额
            const originalTax = calculateTax(originalTaxableIncome);
            
            // 计算新税额
            const newTax = calculateTax(newTaxableIncome);
            
            // 补缴税额 = 新税额 - 原税额
            return newTax - originalTax;
        }
        
        function calculateTax(taxableIncome) {
            if (taxableIncome <= 0) {
                return 0;
            }
            
            let tax = 0;
            
            if (taxableIncome <= 1500) {
                tax = taxableIncome * 0.03;
            } else if (taxableIncome <= 4500) {
                tax = taxableIncome * 0.1 - 105;
            } else if (taxableIncome <= 9000) {
                tax = taxableIncome * 0.2 - 555;
            } else if (taxableIncome <= 35000) {
                tax = taxableIncome * 0.25 - 1005;
            } else if (taxableIncome <= 55000) {
                tax = taxableIncome * 0.3 - 2755;
            } else if (taxableIncome <= 80000) {
                tax = taxableIncome * 0.35 - 5505;
            } else {
                tax = taxableIncome * 0.45 - 13505;
            }
            
            return tax;
        }
    </script>
</body>
</html>